/*
 * @Author: 吕会录 lvhuilu125807@163.com
 * @Date: 2023-08-02 11:13:26
 * @LastEditors: 吕会录 lvhuilu125807@163.com
 * @LastEditTime: 2023-08-04 11:26:13
 * @FilePath: \daping\src\store\index.js
 * @Description:
 * Copyright (c) 2023 by ${git_name} email: ${git_email}, All Rights Reserved.
 */
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)
// 使用vuex-persistedstate插件
const plugins = [createPersistedState()]
const state = {
	token: '',
	roomId: '',
	healthlist: 315, // 今日群动态 健康
	advicelist: 299, // 今日群动态 咨询
	shoplist: 210, // 今日群动态  商场
	servicelist: 381, // 今日群动态 服务
	activelist: 258, // 今日群动态 活动
	interactionlist: 378, // 今日群数据 互动
	guanhuailist: 252, // 今日群sop 关怀
	yuyuelist: 363, // 今日群sop 预约
	shangchenglist: 296, // 今日群sop 商城
	fuwulist: 233, // 今日群sop 服务
	qunList: '',
	indexHs: '',
	// 预警的所有的数量
	yjList: '',
	// messageLists: [],
	orgId: '',
	adminInfo: {
		avatar: 'default.jpg'
	},

	//  储存实时预警监测 obj
	realTime: {}

}

const mutations = {
	settoken(state, value) {
		state.token = value
	},
	addguanhuailist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.guanhuailist += randomNum
	},
	addyuyuelist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.yuyuelist += randomNum
	},
	addshangchenglist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.shangchenglist += randomNum
	},
	addfuwulist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.fuwulist += randomNum
	},
	addhealthlist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.healthlist += randomNum
	},
	addinteractionlist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.interactionlist += randomNum
	},
	addadvicelist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		console.log(state.advicelist)
		state.advicelist += randomNum
		console.log(state.advicelist)
	},
	addshoplist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.shoplist += randomNum
	},
	addservicelist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.servicelist += randomNum
	},
	addactivelist(state) {
		const randomNum = Math.floor(Math.random() * 2) + 1;
		state.activelist += randomNum
	},
	saveAdminInfo(state, adminInfo) {
		state.adminInfo = adminInfo;
	},

	saveRoomId(state, roomIds) {
		state.roomId = roomIds;
	},
	savequnList(state, qunLists) {
		state.qunList = qunLists;
	},
	saveorgId(state, orgId) {
		state.orgId = orgId;
	},
	// smessageLists(state, messageLists) {
	//     state.messageLists = messageLists;
	// },
	smessyjList(state, yjList) {
		console.log("yjListyjList", yjList);
		state.yjList = yjList;
	},
	smessindexHs(state, indexHs) {

		state.indexHs = indexHs;
	},
	saveRealTime(state, realTime) {
		console.log(realTime);
		state.realTime = {};
		state.realTime = realTime;
	}




}

const actions = {
	addguanhuailist(state) {
		state.commit('addguanhuailist')
	},
	addyuyuelist(state) {
		state.commit('addyuyuelist')
	},
	addshangchenglist(state) {
		state.commit('addshangchenglist')
	},
	addfuwulist(state) {
		state.commit('addfuwulist')
	},
	smessyjListasyn(state, smessyjList) {
		console.log("smessyjListsmessyjList", smessyjList);
		state.commit('smessyjList', smessyjList)
	},
	addhealthlist(state) {
		state.commit('addhealthlist')
	},
	addadvicelist(state) {
		state.commit('addadvicelist')
	},
	addshoplist(state) {
		state.commit('addshoplist')
	},
	addservicelist(state) {
		state.commit('addservicelist')
	},
	addactivelist(state) {
		state.commit('addactivelist')
	},
	addinteractionlist(state) {
		state.commit('addinteractionlist')
	}
}

export default new Vuex.Store({
	state,
	actions,
	mutations,
	plugins
})